package com.sz.biz.common.platform.service.impl;

import com.sz.biz.common.platform.entity.PlatformCompanyBank;
import com.sz.biz.common.platform.entity.PlatformCompanyBankInfo;
import com.sz.biz.common.AbstractVersionEntityService;
import com.sz.biz.common.platform.service.PlatformCompanyBankService;
import com.sz.common.base.dao.ParamData;
import com.sz.common.core.service.PrincipalUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Function: 平台公司银行信息 <br>
 * Author: jifeixing <br>
 * Date: 2017-10-09 14:19:00
 */
@Service
public class PlatformCompanyBankServiceImpl extends AbstractVersionEntityService implements PlatformCompanyBankService {

    @Override
    public void save(PlatformCompanyBankInfo platformCompanyBankInfo) {
        PlatformCompanyBank platformCompanyBank = new PlatformCompanyBank();
        BeanUtils.copyProperties(platformCompanyBankInfo, platformCompanyBank);
        platformCompanyBank.setCreateUserId(PrincipalUtils.getAccountId());
        platformCompanyBank.setLastUpdateUserId(PrincipalUtils.getAccountId());
        dao.save(getSqlName("PlatformCompanyBankMapper.insertSelective"), platformCompanyBank);
    }

    @Override
    public List<PlatformCompanyBank> findAll(Integer platformCompanyId) {
        return dao.findForList(getSqlName("PlatformCompanyBankMapper.findAll"), platformCompanyId, PlatformCompanyBank.class);
    }

    @Override
    public PlatformCompanyBank findById(Integer id) {
        return (PlatformCompanyBank) dao.findForObject(getSqlName("PlatformCompanyBankMapper.findById"), id);
    }

    @Override
    public void update(PlatformCompanyBankInfo platformCompanyBankInfo) {
        PlatformCompanyBank platformCompanyBank = new PlatformCompanyBank();
        BeanUtils.copyProperties(platformCompanyBank, platformCompanyBankInfo);
        platformCompanyBank.setLastUpdateUserId(PrincipalUtils.getAccountId());
        dao.update(getSqlName("PlatformCompanyBankMapper.updateByPrimaryKeySelective"), platformCompanyBank);
    }

    @Override
    public void batchDeleteByIds(List<Integer> ids) {
        ParamData paramData = new ParamData();
        paramData.put("ids", ids);
        dao.delete(getSqlName("PlatformCompanyBankMapper.batchDeleteByIds"), paramData);
    }
}
